use arcdps::imgui::sys;
use std::ffi::CString;
pub fn item_context_menu(str_id: impl Into<String>, contents: impl FnOnce()) {
if let Ok(str_id) = CString::new(str_id.into()) {
if unsafe {
sys::igBeginPopupContextItem(
str_id.as_ptr(),
sys::ImGuiPopupFlags_MouseButtonRight as i32,
)
} {
contents();
unsafe { sys::igEndPopup() };
}
}
}
pub fn window_context_menu(str_id: impl Into<String>, contents: impl FnOnce()) {
if let Ok(str_id) = CString::new(str_id.into()) {
if unsafe {
sys::igBeginPopupContextWindow(
str_id.as_ptr(),
sys::ImGuiPopupFlags_MouseButtonRight as i32,
)
} {
contents();
unsafe { sys::igEndPopup() };
}
}
}